<?php
require '../config.php';
if($_POST['reply']){
	$result = mysql_query("update comment set reply='".$_POST['reply']."' , r_time=now() where id=".$_POST['id']."");
	echo $result;
}
?>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta name="author" content="www.frebsite.nl" />
		<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
		<meta name="robots" content="noindex, nofollow" />
		<title>回复评论 - 后台管理系统</title>
        <link rel="stylesheet" href="../public/css/docs.css" />
</head>
<body>
<div id="page">
   <div id="header">回复评论 - 后台管理系统<a href="#" class="right" id="out"></a></div>  
   <div id="content">
        <div id="articlebox">
			        <p><a href="#" id="goback" style="text-decoration:none;font-weight:bold;color:#1d953f;font-size:12px;"><< 返回</a></p>
			    <?php
                     $result = mysql_query("select * from comment where reply is NULL order by id desc");
                     while($row = mysql_fetch_array($result)){
						 

						 $atc = mysql_fetch_row(mysql_query("select title,content from article where id=".$row['aid'].""));
                         echo '<div class="msgbox">';
						 echo '<p>标题 : '.$atc[0].'</p>';
						 echo '<p>评论 : '.$row['details'].'【 <a class="addCmt" href="'.$row['id'].'">回复</a> 】</p>';
						 echo '</div>';
					 }
					 echo '<b>暂无未回复的评论！</b>';
                ?>
			        
        </div>	
   </div>
</div>
<script type="text/javascript" src="../public/js/jquery-1.11.0.min.js"></script>
<script>
$(function(){
	$('#out').bind('click',function(){
		if(confirm('确认离开?')){
            window.location.href = '../index.php';
		}else{
            return;
		}
	});
	$('#show_menu').bind('click',function(){
           $(this).children('div#menu').slideToggle();
	});
	$('#goback').bind('click',function(){
		   window.location.href = 'func.php';
	});

	$('.addCmt').bind('click',function(){
	 	   var self = $(this);
		   if(self.text() == "回复"){
			   self.text('撤销');
               var $form = '<div class="replyBox"><form id="form1"><input type="hidden" name="id" value="'+self.attr('href')+'" />'
			       +'<textarea name="reply" class="reply" style="width:95%;resize:none;" rows=3></textarea>'
			      +'<input type="submit" name="submit" class="submit" value="提交回复" /></form></div>';
		        self.parent().parent().append($form);
			 }else{
                   $('.replyBox').remove();
                   self.text('回复');
  			 };
		  
	       $('input[name=submit]').bind('click',function(){
	  	        if($('.reply').val().length < 5){
		             alert('回复内容不得少于5个字符');	  
		        }else{
					$.post('./reply.php',$('#form1').serialize(),function(data){
						if(data){
							window.location.reload();
							alert('回复成功');
						}else{
                            alert('回复失败');
						}
					}); 
		        };
                return false;
	        });

		   return false;
	});
})
</script>
</body>
</html>
